package com.infosys.cabplanningdao.trip.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.infosys.cabplanning.common.domain.Cab;
import com.infosys.cabplanning.common.domain.Driver;
import com.infosys.cabplanning.common.domain.Schedule;
import com.infosys.cabplanning.common.domain.TripDetails;
import com.infosys.cabplanningdao.cab.dao.impl.CabRowMapper;
import com.infosys.cabplanningdao.driver.dao.impl.DriverRowMapper;
import com.infosys.cabplanningdao.schedule.dao.impl.ScheduleRowMapper;

public class TripDetailsRowMapper implements RowMapper<TripDetails> {

	@Override
	public TripDetails mapRow(ResultSet resultSet, int rowNum) throws SQLException {
		Schedule schedule = new ScheduleRowMapper().mapRow(resultSet, rowNum);
		Cab cab = new CabRowMapper().mapRow(resultSet, rowNum);
		Driver driver = new DriverRowMapper().mapRow(resultSet, rowNum);
		TripDetails tripDetails= new TripDetails();
		tripDetails.setCab(cab);
		tripDetails.setDriver(driver);
		tripDetails.setSchedule(schedule);
		tripDetails.setTripDetailsId(resultSet.getInt("trip_details_id"));
		return tripDetails;
	}

}
